﻿using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using Servicios.Business.Modulos;

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class AutorService
{
    // Add [WebGet] attribute to use HTTP GET
    [OperationContract]
    public string[] GetCompletionList(string prefixText, int count)
    {
        Busqueda res = new Busqueda();
        List<string> autores = new List<string>();
        foreach (var item in res.GetAutoresByPrefix(prefixText).Take(count))
        {
            //para identificar con ID
            //autores.Add(string.Format("[{0}] - {1}", ));

            autores.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(item.Autor.ToString(), item.Autor.ID.ToString()));
        }
        return autores.ToArray();
    }

    // Add more operations here and mark them with [OperationContract]
}
